import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import { fileURLToPath, URL } from "node:url";

import { resolve } from "path";
import path from "path";
//import vue from '@vitejs/plugin-vue'  // 注释掉，因为 uni-app 会自动处理

export default defineConfig({
  plugins: [uni()],
  resolve: {
    alias: {
      "@": resolve(__dirname, "src"),

      "@components": fileURLToPath(
        new URL("./src/components", import.meta.url)
      ),
      "@stores": fileURLToPath(new URL("./src/stores", import.meta.url)),
    
    },
  },

  build: {
    // rollupOptions: {
    //   external: ["@dcloudio/uni-ui/lib/uni-button/uni-button.vue"],
    // },
    minify: "terser",
    terserOptions: {
      compress: {
        drop_console: true,
        drop_debugger: true,
      },
    },
  },
  // css: {
  //   preprocessorOptions: {
  //     scss: {
  //       api: "modern-compiler",
  //     },
  //   },
  // },
  // npm install sass@1.32.0 --save-dev
  server: {
    port: 3000,
    proxy: {
      "/api": {
        target:
          "https://fc-mp-d7d620be-76ea-43bb-a05a-d38ceb13c655.next.bspapp.com",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
});
